Overview
Enumeration is the process by which the host discovers and configures a newly attached USB device. It occurs automatically when a device is plugged in and involves reading descriptors, assigning an address, and loading the appropriate driver.
Enumeration Steps
When a device is connected:
1. Device Attachment and Reset
- The hub detects a change on its downstream port (electrical signaling).
- The hub reports the port status change to the host via an Interrupt IN transfer.
- The host issues a port reset to the hub port.
- After reset, the device operates at its default address (0) and is in the Default state.
2. Read Device Descriptor (Partial)
- The host sends a GET_DESCRIPTOR request to address 0, endpoint 0.
- Initially, only the first 8 bytes of the Device Descriptor are read.
- This reveals the maximum packet size for endpoint 0 (
bMaxPacketSize0).
3. Assign Unique Address
- The host issues a SET_ADDRESS request with a unique address (1–127).
- The device transitions to the Address state.
- All subsequent communication uses this new address.
4. Read Full Device Descriptor
- The host reads the complete 18-byte Device Descriptor.
- Key fields retrieved: VID, PID, device class, number of configurations.
5. Read Configuration Descriptors
- The host sends GET_DESCRIPTOR for each configuration.
- The response includes the Configuration Descriptor and all subordinate descriptors:
- Interface Descriptors
- Endpoint Descriptors
- Class-specific descriptors (if any)
6. Select Configuration
- The host sends a SET_CONFIGURATION request.
- The device enters the Configured state and is ready for normal use.
7. Driver Loading
- The host identifies the device class from the descriptors.
- The appropriate class driver is loaded.
- The driver may perform additional class-specific initialization.
Example: USB Keyboard
Descriptor structure:
Device Descriptor
└── Configuration Descriptor
└── Interface Descriptor (HID)
├── HID Descriptor
└── Endpoint Descriptor (Interrupt IN)
- Host detects the HID class (
bInterfaceClass = 0x03) - Loads the built-in HID keyboard driver
- Driver sets the idle rate and report protocol via class-specific requests
Device States During Enumeration
| State | Description |
|---|---|
| Attached | Device is physically connected but not yet powered |
| Powered | Hub supplies VBUS to the device |
| Default | Device has been reset; responds on address 0 |
| Address | Device has been assigned a unique address |
| Configured | A configuration has been selected; device is operational |
Host Software Responsibilities
After reading descriptors, the host:
- Allocates memory structures for each endpoint
- Creates communication pipes (logical connections between host buffer and device endpoint)
- Loads the correct driver
- Configures the device for normal operation
Tip
The host must handle enumeration failures gracefully — if a device does not respond correctly during any step, the host may retry or disable the port.